<?php

namespace app\admin\controller;

use app\common\model\order\BabycarOrder as BabycarOrderModel;


/**
 * TP Babycar 订单管理
 */
class BabycarOrder extends Controller
{
    /**
     * 订单列表
     * @return \think\response\Json
     */
    public function list()
    {
        $params = $this->request->param();
        $model = new BabycarOrderModel();
        $list = $model->getList($params);
        return json(['code' => 0, 'msg' => 'success', 'data' => $list]);
    }

    /**
     * 订单详情
     * @param int $order_id 订单ID
     * @return \think\response\Json
     */
    public function detail($order_id)
    {
        $model = new BabycarOrderModel();
        $detail = $model->getDetail($order_id);
        if (!$detail) {
            return json(['code' => 1, 'msg' => '订单不存在']);
        }
        return json(['code' => 0, 'msg' => 'success', 'data' => $detail]);
    }

    /**
     * 删除订单
     * @param int $order_id 订单ID
     * @return \think\response\Json
     */
    public function delete($order_id)
    {
        $model = new BabycarOrderModel();
        $result = $model->deleteOrder($order_id);
        if (!$result) {
            return json(['code' => 1, 'msg' => '删除失败']);
        }
        return json(['code' => 0, 'msg' => '删除成功']);
    }
} 